package com.zhouxiaoge.source;

import com.zhouxiaoge.Event;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

import java.util.ArrayList;
import java.util.List;

/**
 * @author 周小哥  gqzmy@163.com 2022/8/12 23:07
 * <p>
 * 从集合中读取数据
 */

public class CollectionSourceTest {

    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);

        List<Event> events = new ArrayList<>();
        events.add(new Event("小哥", "/home", 1000L));
        events.add(new Event("张三", "/order", 2000L));
        events.add(new Event("李四", "/pay", 3000L));
        events.add(new Event("王二", "/home", 4000L));
        events.add(new Event("麻子", "/bobo", 5000L));

        DataStreamSource<Event> source = env.fromCollection(events);
        source.print();

        env.execute();
    }
}
